import React from 'react'
import Router,{Link} from'react-router'
import actions from './actions'
import Reflux from 'reflux'
import ReactMixin from 'react-mixin'
import store from './store'



export default class AddressCard extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            isDef:this.props.isDef,
        }
    }

    componentDidMount(){
        actions.getAddressList()
    }

    render() {
        return (
            <div className="address-card">
                <div className="address-card-top">
                    <div className="address-card-top-info">
                        <p className="address-card-name">{this.props.name}</p>
                        <p className="address-card-phone">{this.props.phone}</p>
                    </div>
                    <div className="address-card-address">
                        {this.props.address + this.props.place}
                    </div>
                </div>

                <div className="address-card-foot">
                    <div className="address-card-btn">
                        <div className={`address-card-btn-1 ${this.props.isDef ? "active" : ""}`} onClick={this.props.selectIndex.bind(this)}>
                            <span></span>
                        </div>
                        默认地址</div>
                    <div className="address-card-set">
                        <Link to={`/address/edit?index=${this.props.index}`} className="address-card-set-bj"
                        onClick={this.props.editInfo.bind(this)}>
                            <i className="iconfont icon-bianji"></i>
                            编辑
                        </Link>
                        <div className="address-card-set-del"  onClick={this.props.removeInfo.bind(this)}>
                            <i className="iconfont icon-shanchu">
                            </i>删除
                        </div>
                    </div>


                </div>

                <Link to="/address/add">
                    <div className="address-btn">
                        <i className="iconfont icon-add">

                        </i>添加地址</div>
                </Link>
            </div>
        )
    }
}
ReactMixin.onClass(AddressCard, Reflux.connect(store));